<template>
	<view class="shouyiTZ">
		<view class="top">
			<view class="myshouru">
				可提现金额 {{jianglijine}}（元）
			</view>
			<input class="jine" v-model="canshu.money" type="number" value="" placeholder="0" />
			<!-- 	<view class="jine">
				150.00
			</view> -->
			<view class="tupian">
				<image @click="tixianBtn" class="img" src="../../static/user/tixianBtn.png" mode=""></image>
			</view>
		</view>
		<view class="wodshouyi">
			提现记录
		</view>
		
		<view class="jilu" v-for="item in datalist">
			<view class="right">
				<text class="name" v-show="item.status=='0'">待审核</text>
				<text class="name" v-show="item.status=='1'">已打款</text>
				<text class="name" v-show="item.status=='2'">已拒绝</text>
				<text class="jinea">{{item.money}}</text>
				<text class="name">元</text>
			</view>
			<view class="left">
				<text class="name">{{timestampToTime(item.gmtCreate) }}</text>
			</view>
		</view>
		<!-- <view class="jilu" v-show="wujiluShow">
			暂无提现记录
		</view> -->

	</view>
</template>
<script>
	import {
		mapState
	} from 'vuex';

	export default {
		components: {

		},
		data() {
			return {
				wujiluShow:false,
				inputjine: '',
				jianglijine: 0,
				canshu: {
					money: 0,
					userId: ''
				},
				
				chuanru:{
					userId:'',
					pageNo: 1,
					limit: '10',
				},
				datalist: []
			}
		},
		//下拉刷新
		onPullDownRefresh() {
			console.log('下拉刷新')
			// this.loadData('refresh');
		},
		//加载更多
		onReachBottom() {
			console.log('加载更多')
			// this.loadData();
		},
		onShow() {
			this.userInfotz = uni.getStorageSync('userInfo')
			this.canshu.userId = this.userInfotz.id
			this.chuanru.userId = this.userInfotz.id
			
			this.chauxn()
			this.getlist()

		},
		onLoad() {

		},

		computed: {
			...mapState(['hasLogin', 'userInfo'])
		},
		methods: {
			//获取list
			getlist() {
				
				var that = this
				uni.showLoading({

				})
				that.$api.request('admin.chief', 'getUserRewardList', this.chuanru, failres => {
					that.$api.msg(failres.errmsg)
					uni.hideLoading()
				}).then(res => {
					uni.hideLoading()
					if (res.errno == '200') {
						this.datalist = res.data
						if(this.datalist.length==0){
							this.wujiluShow = true
						}else{
							this.wujiluShow = false
						}
					
					}
				})
			},
			timestampToTime(timestamp) {
				var date = new Date(timestamp); //时间戳为10位需*1000，时间戳为13位的话不需乘1000
				var Y = date.getFullYear() + '-';
				var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
				var D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' ';
				var h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
				var m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
				var s = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());

				var strDate = Y + M + D + h + m + s;
				return strDate;

			},
			chauxn() {
				var obj = {}
				obj.userId = this.userInfotz.id
				var that = this
				that.$api.request('user', 'getUserInfo', obj, failres => {
					that.$api.msg(failres.errmsg)
					uni.hideLoading()
				}).then(res => {
					if (res.errno == '200') {
						if (res.data) {
							that.jianglijine = res.data.reward
						}


					}
				})

			},
			//体现
			tixianBtn() {
				console.log('tixian')
				if (this.canshu.money > this.jianglijine) {
					this.$api.msg('余额不足')
					return
				}
				if (this.canshu.money == 0) {
					this.$api.msg('请输入金额')
					return
				}
				var that = this
				that.$api.request('admin.chief', 'addObj', {
					ChiefDo: JSON.stringify(that.canshu)
				}, failres => {
					that.$api.msg(failres.errmsg)
					uni.hideLoading()
				}).then(res => {
					if (res.errno == '200') {
						this.chauxn()
						this.getlist()
					}
				})

			}

		}
	}
</script>
<style lang='scss' scoped>
	.shouyiTZ {
		width: 750rpx;
		height: 100%;

		.fenxiang {
			width: 84rpx;
			height: 88rpx;
			position: fixed;
			right: 36rpx;
			bottom: 160rpx;
		}

		.jilu {
			width: 710rpx;
			height: 108rpx;
			background: #F2F2F2;
			border-radius: 8rpx;
			margin-left: 20rpx;
			margin-bottom: 5rpx;
			padding-left: 16rpx;
			padding-right: 16rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;

			.right {
				display: flex;
				height: 108rpx;
				align-items: center;

				.jinea {
					font-size: 30rpx;
					color: #36B542;
					font-weight: 600;
				}

				.name {
					font-size: 28rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #333333;
				}

			}

			.left {
				display: flex;
				height: 108rpx;
				align-items: center;

				.name {
					margin-left: 16rpx;
					font-size: 28rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #333333;
				}

				.img {
					width: 60rpx;
					height: 60rpx;
					border-radius: 100%;
				}
			}
		}

		.wodshouyi {

			padding-left: 20rpx;
			background-color: #FFFFFF;
			font-size: 36rpx;
			font-family: PingFangSC-Medium, PingFang SC;
			font-weight: 500;
			color: #333333;
			line-height: 100rpx;
		}

		.top {
			width: 750rpx;
			padding-bottom: 20rpx;
			background-color: #68C628;

			.tupian {
				margin-top: 16rpx;
				text-align: center;

				.img {
					width: 100rpx;
					height: 44rpx;
				}
			}

			.jine {
				margin-top: 16rpx;
				text-align: center;
				font-size: 50rpx;
				font-family: PingFangSC-Medium, PingFang SC;
				font-weight: 500;
				color: #FFFFFF;
				/* line-height: 84rpx; */
			}

			.myshouru {
				text-align: center;
				font-size: 24rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #FFFFFF;
			}

		}
	}
</style>
